#! /bin/bash

# 脚本开发

print_usage() {
	printf "Please enter an integer\n"
	# 给脚本的执行结果，赋予一个状态码，退出码
	exit 1
}

# 接收用户输入的命令，-p参数后面写，给用户看到的提示信息
# read -p "提示信息" 接收用户输入的变量 存储到firstnum中
read -p "Please input your number: " firstnum


# 进行对用户输入判断 if

if [ -n "`echo $firstnum|sed 's/[0-9]//g' `" ]
then
	print_usage
fi

read -p "Please input your operator: " operator

if [[ "${operator}" != "+" && "${operator}" != "-" && "${operator}" != "*" && "${operator}" != "/" ]]
then
	echo "只允许输入 +-*/"
	exit 2
fi

read -p "Please input your number: " secondnum

if [ -n "`echo $secondnum|sed 's/[0-9]//g' `" ]
then
        print_usage
fi


echo "${firstnum}${operator}${secondnum}结果是: $((${firstnum}${operator}${secondnum}))"


